package link.jfire.jnet.common.result;

import link.jfire.jnet.client.AioClient;
import link.jfire.jnet.common.exception.SelfCloseException;

public class ClientInternalResult extends AbstractInternalResult
{
	private AioClient aioClient;
	
	public void init(AioClient aioClient, Object data, int index)
	{
		this.aioClient = aioClient;
		this.data = data;
		this.index = index;
	}
	
	public AioClient getClient()
	{
		return aioClient;
	}
	
	public void setClient(AioClient aioClient)
	{
		this.aioClient = aioClient;
	}
	
	public void clear()
	{
		aioClient = null;
		data = null;
		index = 0;
	}
	
	@Override
	public void closeChannel(Throwable e)
	{
		aioClient.close(e);
	}
	
	@Override
	public void closeChannel()
	{
		aioClient.close(new SelfCloseException());
	}
}
